<template>
	<view style="background-color: #FFFFFF;">
		<view class="" v-show="!loadShow">
			<view class="" :style="{marginTop: menuButtonInfo.bottom+'px'}"></view>
			<view class="u-flex u-row-between u-col-center u-p-r-40">
				<view v-if="appconfig.appname" class="user u-p-l-40 u-p-r-40 u-flex u-row-left u-col-center">
					<image class="avatar" :src="appconfig.appicon"></image>
					<view class="u-p-l-20">
						<view class="name u-font-18">{{appconfig.appname}}</view>
					</view>
				</view>
				<view v-else class="user u-p-l-40 u-p-r-40 u-flex u-row-left u-col-center">
					<image class="avatar" src="../../static/icon/headerIcon.jpeg"></image>
					<view class="u-p-l-20">
						<view class="name u-font-18">咪咪表情~</view>
					</view>
				</view>
			</view>
			<view class="u-flex u-row-between u-p-30 border-bottom" hover-class="hover-class1" hover-stay-time="50">
				<view class="u-flex u-row-left">
					<image style="width: 15px;height: 15px;" src="/static/icon/kefu.png"></image>
					<view class="u-p-l-20">联系客服</view>
				</view>
				<view class="u-flex u-row-right">
					<view class="arror-right"></view>
				</view>
				<button open-type="contact"
					style="position: absolute;top: 0;left: 0;width: 100%;height: 100%;opacity: 0;"></button>
			</view>
			<view class="u-flex u-row-between u-p-30 border-bottom" hover-class="hover-class1" hover-stay-time="50"
				@click="exitClick()">
				<view class="u-flex u-row-left">
					<image style="width: 15px;height: 15px;" src="/static/icon/qingchu.png"></image>
					<view class="u-p-l-20">清理缓存</view>
				</view>
				<view class="u-flex u-row-right">
					<view class="u-light-color u-font-12 u-p-r-10">{{currentSize}}kb</view>
					<view class="arror-right"></view>
				</view>
			</view>
			<view @click="aboutClick()" class="u-flex u-row-between u-p-30" hover-class="hover-class1"
				hover-stay-time="50">
				<view class="u-flex u-row-left">
					<image style="width: 15px;height: 15px;" src="/static/icon/guanyu.png"></image>
					<view class="u-p-l-20">关于我们</view>
				</view>
				<view class="u-flex u-row-right">
					<view class="arror-right"></view>
				</view>
			</view>
			<view @click="wodexcxClick()" class="u-flex u-row-between u-p-30" hover-class="hover-class1"
				hover-stay-time="50">
				<view class="u-flex u-row-left">
					<image style="width: 15px;height: 15px;" src="/static/icon/like.png"></image>
					<view class="u-p-l-20">我的小程序</view>
				</view>
				<view class="u-flex u-row-right">
					<view class="arror-right"></view>
				</view>
			</view>
		</view>
		<!-- 底部跳转 -->
		<view class="recommendBgView" v-if="appconfig.recommendApp.length > 0">
			<view class="head">
				<view class="title">推荐小程序</view>
			</view>
			<view class="grid">
				<u-grid :border="false" col="4">
					<block v-for="(item,index) in appconfig.recommendApp" :key="index">
						<u-grid-item v-on:click="appItemClick(item.app_id)">
							<u-icon :name="item.app_logo" :size="70">
							</u-icon>
							<view class="grid-text">{{ item.app_name }}</view>
						</u-grid-item>
					</block>
				</u-grid>
			</view>
		</view>
		<view class="loading_page" v-show="loadShow">
			<image src="/static/loading/loading.gif"></image>
		</view>
	</view>
</template>

<script>
	// 获取系统状态栏的高度
	let menuButtonInfo = {};
	// 如果是小程序，获取右上角胶囊的尺寸信息，避免导航栏右侧内容与胶囊重叠(支付宝小程序非本API，尚未兼容)
	// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
	menuButtonInfo = uni.getMenuButtonBoundingClientRect();
	// #endif

	import Vue from 'vue';

	export default {

		data() {
			return {
				currentSize: 0,
				menuButtonInfo: menuButtonInfo,
			};
		},
		async onLoad() {
			let that = this;
			var res = uni.getStorageInfoSync();
			that.currentSize = res.currentSize - 1;
		},
		methods: {
			exitClick() {
				let that = this;
				uni.getStorageInfo({
					success(res) {
						res.keys.forEach((item, index, array) => {
							uni.removeStorageSync(item);
						});
						uni.showToast({
							icon: 'none',
							title: '清除成功'
						});
						uni.getStorageInfo({
							success(res) {
								that.currentSize = res.currentSize - 1;
							}
						});
					}
				});
			},
			aboutClick() {
				uni.navigateTo({
					url: '../about/about'
				})
			},
			wodexcxClick(){
				uni.navigateTo({
					url: '../myApp/myApp'
				})
			},
			appItemClick(wxAppID) {
				uni.navigateToMiniProgram({
					appId: wxAppID,
					// path: item.wxInitPath,
					extraData: {},
					success(res) {
						// 打开成功
						console.log(res)
					},
					fail(err) {
						console.log(err)
					}
				})
			},
		},
		onShareTimeline() {
			var share = {
				share_title: "节日头像",
				share_desc: "节日头像",
				share_img: ""
			}
			if (this.appconfig.shareInfo.status == 1) {
				share = this.appconfig.shareInfo
			}
			return {
				title: share.share_title,
				imageUrl: share.share_img,
				desc: share.share_desc,
			}
		},
		onShareAppMessage() {
			var share = {
				share_title: "节日头像",
				share_desc: "节日头像",
				share_img: ""
			}
			if (this.appconfig.shareInfo.status == 1) {
				share = this.appconfig.shareInfo
			}
			return {
				title: share.share_title,
				imageUrl: share.share_img,
				desc: share.share_desc,
			}
		}
	};
</script>
<style lang="scss" scoped>
	.user {
		.avatar {
			width: 116rpx;
			height: 116rpx;
			border-radius: 116rpx;
			overflow: hidden;
		}

		.name {
			font-size: 20px;
			font-weight: 500;
		}
	}

	.jifen {
		.tab {
			position: relative;
			background-color: #FFFFFF;
			width: 234rpx;
			margin-right: 10rpx;
			margin-left: 10rpx;

			.title {
				font-weight: 550;
			}

			.icon {
				width: 80rpx;
				height: 80rpx;
				border-radius: 80rpx;
			}
		}

		.tab:nth-child(1) .icon {
			background-image: linear-gradient(to right, #84D787, #5FBB92);
		}

		.tab:nth-child(2) .icon {
			background-image: linear-gradient(to right, #F5D553, #F0B347);
		}

		.tab:nth-child(2) .icons {
			background-image: linear-gradient(to right, #dadada, #dadada);
		}

		.tab:nth-child(3) .icon {
			background-image: linear-gradient(to right, #ee6c6c, #f0513c);
		}
	}

	.border-box {
		box-shadow: 0 0px 24px rgba(231, 231, 231, 0.65);
		border-radius: 16rpx;
	}

	.menu {
		image {
			width: 38rpx;
			height: 38rpx;
		}
	}

	.border-bottom {
		border-bottom: 1rpx solid #F6F6F6;
		position: relative;
	}

	.hover-class {
		transform: scale(0.95);
		transition: all 0.2s;
	}

	.hover-class1 {
		background-color: #F8F8F8;
	}

	.arror-right {
		width: 15rpx;
		height: 15rpx;
		border-top: 3rpx solid #a9acb3;
		border-right: 3rpx solid #a9acb3;
		transform: rotate(45deg);
	}

	.recommendBgView {
		padding: 10px;

		.head {
			.title {}
		}

		.grid {
			.grid-text {
				margin-top: 5px;
			}
		}
	}
</style>